package br.com.bikes4bikers.dao.impl;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import br.com.bikes4bikers.dao.UsuarioDAO;
import br.com.bikes4bikers.model.Funcionario;
import br.com.bikes4bikers.model.Usuario;

@Repository("funcionarioDAO")
public class FuncionarioDAOImpl extends AbstractDAOImpl<Funcionario, Integer> implements UsuarioDAO<Funcionario>{

	@Override
	public Funcionario pesquisarUsuarioPorEmail(String email) {
		StringBuffer sql = new StringBuffer("SELECT obj from ")
		.append(Usuario.class.getSimpleName()).append(" obj where email = :paramEmail");
		Query query = getEntityManager().createQuery(sql.toString());
		query.setParameter("paramEmail", email);
		return (Funcionario) query.getSingleResult();
	}
}
